const log = require('j7/log');
const bcutils = require('j7/bcutils');
const utils = require('j7/utils');
const bcconst = require('common/bcconst');
const BaseEventProcess = require('../common/BaseEventProcess');
const metaFactory = require('../../../metadata/factory');

class NftLock extends BaseEventProcess {

  async start() {
    const returnValues = this.getReturnValues();
    const nft = bcutils.toNormalAddress(returnValues['nft']);
    const sender = bcutils.toNormalAddress(returnValues['sender']);
    const to = bcutils.toNormalAddress(returnValues['to']);

    const nowTime = utils.getUtcTime();
    {
      const {err} = await this.bcEventDbConn(
        'update',
        't_nft_lock_event',
        [
          ['idx', this.getEventDb()['idx']],
        ],
        [
          ['lock_sender', sender],
          ['lock_to', to],
        ]
      );
      if (err) {
        this.throwError('NftLock:' + err);
      }
    }
    await this.markOk();
  }

}

module.exports = NftLock;
